<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>

    <meta charset="utf-8">
    <meta content="width=device-width, initial-scale=1.0" name="viewport">


    <title>X+ 约课系统 - 个人资料</title>
    <meta content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台" name="keywords">
    <meta content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术" name="description">

    <link href="../../static/favicon.ico" rel="shortcut icon" th:href="@{/static/favicon.ico}">
    <link href="../../static/css/bootstrap.min.css?v=3.3.6" rel="stylesheet"
          th:href="@{/static/css/bootstrap.min.css(v='3.3.6')}">
    <link href="../../static/css/font-awesome.css?v=4.4.0" rel="stylesheet"
          th:href="@{/static/css/font-awesome.css(v='4.4.0')}">
    <link href="../../static/css/animate.css" rel="stylesheet" th:href="@{/static/css/animate.css}">
    <link href="../../static/css/style.css?v=4.1.0" rel="stylesheet" th:href="@{/static/css/style.css(v='4.1.0')}">
    <!-- bootstrap-datepicker -->
    <link href="../../static/css/plugins/datapicker/datepicker3.css"
          rel="stylesheet" th:href="@{/static/css/plugins/datapicker/datepicker3.css}">
    <link href="../../static/css/plugins/sweetalert/sweetalert.css"
          rel="stylesheet" th:href="@{/static/css/plugins/sweetalert/sweetalert.css}">

</head>

<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>添加老师</h5>
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        <!--                        <form id="addForm" method="post" class="form-horizontal" th:action="@{/user/teacherAdd.do}" >-->
                        <form class="form-horizontal" id="addForm" method="post">
                            <div class="form-group">
                                <label class="col-sm-2 control-label"><i class="red">*</i>老师姓名</label>
                                <div class="col-sm-6">
                                    <input class="form-control" name="name" placeholder="请输入老师的姓名" type="text">
                                </div>

                                <div class="col-sm-4">
                                    <label class="control-label" tip="name"></label>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label"><i class="red">*</i>手机号</label>
                                <div class="col-sm-6">
                                    <input class="form-control" name="phone" placeholder="请输入手机号码" type="text">
                                    <!--<span class="text-danger" th:if="${CHECK_PHONE_EXIST}">手机号跟其它用户撞名了</span>-->
                                </div>

                                <div class="col-sm-4">
                                    <label class="control-label" tip="phone"></label>
                                </div>

                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label"><i class="red">*</i>邮 箱</label>
                                <div class="col-sm-6">
                                    <input class="form-control" name="roleEmail" placeholder="请输入合法的邮箱" type="email">
                                </div>

                                <div class="col-sm-4">
                                    <label class="control-label" tip="roleEmail"></label>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label"><i class="red">*</i>性 别</label>
                                <div class="col-sm-6">
                                    <label class="checkbox-inline">
                                        <input name="sex" type="radio" value="男"> 男
                                    </label>
                                    <label class="checkbox-inline">
                                        <input checked name="sex" type="radio" value="女"> 女
                                    </label>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label" for="myDate">
                                    出生日期</label>
                                <div class="col-sm-3">
                                    <input class="form-control" id="myDate" name="birthday" placeholder="yyyy-mm-dd"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">老师介绍</label>
                                <div class="col-sm-6">
                                    <textarea class="form-control" name="introduce" placeholder="-讲师的简要介绍-"></textarea>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">备注</label>
                                <div class="col-sm-6">
                                    <textarea class="form-control" name="note"></textarea>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-2 col-sm-offset-2">
                                    <button class="btn btn-success" type="submit">保存</button>
                                    <button class="btn btn-white" onclick="window.history.go(-1)" type="reset">取消</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 全局js -->
<script src="../../static/js/jquery.min.js?v=2.1.4" th:src="@{/static/js/jquery.min.js(v='2.1.4')}"></script>
<script src="../../static/js/bootstrap.min.js?v=3.3.6" th:src="@{/static/js/bootstrap.min.js(v='3.3.6')}"></script>

<!-- 自定义js -->
<script src="../../static/js/content.js?v=1.0.0" th:src="@{/static/js/content.js(v='1.0.0')}"></script>

<!-- Peity -->
<script src="../../static/js/plugins/peity/jquery.peity.min.js"
        th:src="@{/static/js/plugins/peity/jquery.peity.min.js}"></script>

<!-- Peity -->
<!-- <script src="../../static/js/demo/peity-demo.js" th:src="@{/static/js/demo/peity-demo.js}"></script> -->


<!-- Data picker -->
<script src="../../static/js/plugins/datapicker/bootstrap-datepicker.js"
        th:src="@{/static/js/plugins/datapicker/bootstrap-datepicker.js}"></script>
<script src="../../static/js/plugins/datapicker/bootstrap-datepicker.zh-CN.min.js"
        th:src="@{/static/js/plugins/datapicker/bootstrap-datepicker.zh-CN.min.js}"></script>
<script src="../../static/js/plugins/sweetalert/sweetalert.min.js"
        th:src="@{/static/js/plugins/sweetalert/sweetalert.min.js}"></script>

<script>
    $(function () {
        $('#addForm').on('submit', function (e) {
            e.preventDefault();
            var serialize = $(this).serialize();

            swal({
                title: "您确定要添加该老师吗？",
                text: "注意:您正在添加一个新的老师！",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "确认",
                closeOnConfirm: true
            }, function () {
                $.ajax({
                    url: '[[${#request.getContextPath()}]]/user/teacherAdd.do',
                    type: 'post',
                    data: serialize,
                    dataType: 'json',
                    success: function (data) {
                        if (data.code === 0) {
                            setTimeout(function () {

                            },100);
                            swal(data.msg, "", "success");
                            setTimeout(function () {
                                window.location.href = '[[${#request.getContextPath()}]]/user/x_teacher_list.do'
                            }, 1500);
                        }else if (data.code === 400) {
                            let errors = data.errorMap;
                            for (const key in errors) {
                                $(`[tip=${key}]`).html("");
                                //错误提示回显
                                $("<span class='text-danger'>" + errors[key] + "</span>").appendTo($("[tip=" + key + "]"));
                            }
                        }  else {
                            swal("添加老师失败！！", data.msg, "info");
                            setTimeout(function () {
                                window.location.reload();
                            }, 2000);
                        }
                    }
                });
            });
        });
    });
</script>


<script type="text/javascript">
    $(function () {
        /*时间控件配置*/
        $('#myDate').datepicker({
            language: "zh-CN",
            clearBtn: true,//清除
            autoclose: true,
            todayHighlight: true,
            format: 'yyyy-mm-dd',
            todayBtn: false,//今日按钮
            startDate: '1970-1-1', //与你自己设置的格式一致yyyy-mm-dd，未设置的话与默认格式一致mm/dd/yyyy
            endDate: '2070-1-1'
        });
    });
</script>
</body>

</html>
